package service

import (
	"MessageSendService/app/api/internal/db"
	"MessageSendService/app/common/log"
	"MessageSendService/app/common/models/accounts"
	"go.uber.org/zap"
	"gorm.io/gorm"
)

type AccountService struct {
}

func NewAccountService() *AccountService {
	return &AccountService{}
}

func (a AccountService) db() *gorm.DB {
	return db.Db
}

// GetById 根据id获取消息模板
func (a AccountService) GetById(id int64) (accounts.SendAccount, error) {
	//查找数据库
	var account accounts.SendAccount

	err := a.db().Take(&account, id).Error
	if err != nil {
		log.GetLogger().Error("accountService GetById error", zap.Error(err))
		return accounts.SendAccount{}, err
	}
	return account, nil
}
